function LocationObject(x,y){
	////////////////////////////////////////////////////////////////////////////
	//Clearing/Initializing
	////////////////////////////////////////////////////////////////////////////
	var innerX;
	var innerY;

	////////////////////////////////////////////////////////////////////////////
	//Getters and Setters for X and Y
	////////////////////////////////////////////////////////////////////////////
	this.setX = function(x){
		innerX = Number(x);
	};
	this.getX = function(){
		return innerX;
	};
	this.setY = function(y){
		innerY = Number(y);
	};
	this.getY = function(){
		return innerY;
	};
	this.clear = function(){
		this.setX(0);
		this.setY(0);
	}
	
	////////////////////////////////////////////////////////////////////////////
	//Getters and Setters for Radius and Theta
	////////////////////////////////////////////////////////////////////////////
	this.getRadius = function(){
		return Math.sqrt(this.getX()*this.getX()+this.getY()*this.getY());
	};
	this.setRadius = function(radius){
		var theta = this.getTheta();
		this.setX(radius * Math.cos(theta));
		this.setY(radius * Math.sin(theta));
	};
	this.getTheta = function(){
		var theta = Math.atan2(this.getY(),this.getX());
		if(isNaN(theta)) return 0;
		return theta;
	};
	this.setTheta = function(theta){
		var radius = this.getRadius();
		this.setX(radius * Math.cos(theta));
		this.setY(radius * Math.sin(theta));
	};
	
	////////////////////////////////////////////////////////////////////////////
	//Operations concerning other location objects
	////////////////////////////////////////////////////////////////////////////
	this.copyLocation = function(location){
		this.setX(location.getX());
		this.setY(location.getY());
	};
	this.addLocation = function(location){
		this.setX(this.getX()+location.getX());
		this.setY(this.getY()+location.getY());
	};
	this.getDistanceBetween = function(location){
		return Math.sqrt((this.getX()-location.getX())*(this.getX()-location.getX())+(this.getX()-location.getY())*(this.getY()-location.getY()));
	};
	this.getDirectionTo = function(toLocation){
		return Math.atan2(toLocation.getY()-this.getY(),toLocation.getX()-this.getX());
	};
	
	////////////////////////////////////////////////////////////////////////////
	//Serialization functions
	////////////////////////////////////////////////////////////////////////////
	this.getGameData = function(){
		var data = {};
		data.x = this.getX();
		data.y = this.getY();
		return data;
	};
	this.setGameData = function(data){
		this.clear();
		this.setX(data.x);
		this.setY(data.y);
	};

	////////////////////////////////////////////////////////////////////////////
	//Apply constructor parameters
	////////////////////////////////////////////////////////////////////////////
	this.clear();
	this.setX((x==null)?(0):(x));
	this.setY((y==null)?(0):(y));
}
LocationObject.clone = function(originalLocation){
	var result = new LocationObject();
	result.copyLocation(originalLocation);
	return result;
}
